package com.dreamtour.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dreamtour.DTO.ApplicationDTO;
import com.dreamtour.entity.Agencies;
import com.dreamtour.mapper.AgenciesMapper;
import com.dreamtour.service.IAgenciesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xls
 * @since 2024-12-24
 */
@Service
public class AgenciesServiceImpl extends ServiceImpl<AgenciesMapper, Agencies> implements IAgenciesService {
    @Autowired
    private AgenciesMapper agenciesMapper;

    @Override
    public List<Map<String, Object>> countAgenciesByMonth() {
        QueryWrapper<Agencies> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("count(*) as count, DATE_FORMAT(applyingTime, '%m') as month");
        queryWrapper.eq("qualifyStatus", 0);
        queryWrapper.groupBy("month");
        queryWrapper.orderByDesc("month");
        return agenciesMapper.selectMaps(queryWrapper);
    }


}
